// pages/my/setting/setting.js
Page({
  data: {
    account_status: 0,
    userInfo: {}
  },
  onShow: function () {
    getApp().globalData.http.getAccountState().then(res => {
      this.setData({
        account_status: res.data.status
      });
    });
    this.setData({
      userInfo: wx.getStorageSync("userInfo")
    });
  },
  navTo(e) {
    let path = e.currentTarget.dataset.path;
    wx.navigateTo({
      url: path,
    })
  },
  unBlock() {
    if (this.data.account_status == 0) {
      getApp().globalData.vant.toast("您的账号没有被封停哦~");
    } else {
      wx.navigateTo({
        url: "/pages/my/unblockedapply/unblockedapply",
      })
    }
  },
  logout() {
    getApp().globalData.http.logout().then(res => {
      wx.clearStorage();
      getApp().globalData.vant.toast({
        type: "success",
        message: "退出成功",
        duration: 1000,
        onClose: () => {
          // 登录
          wx.login({
            success: res => {
              // 发送 res.code 到后台换取 openId, sessionKey, unionId
              getApp().globalData.code = res.code;
              wx.redirectTo({
                url: "/pages/login/login"
              });
            }
          });
        },
      });
    });
  }
})